home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / Campaign1Startup.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  11.9 KB  |  430 lines

  1. -----------------------
  2. -- TEMPORARY!
  3. -----------------------
  4.  
  5.  
  6.  
  7. -- This is the sequence where the Basic is introduced
  8. function BasicCinematic()
  9.     
  10.     -- Look at tower, traitor keeps talking, then (Oh no!) 
  11.     -- basic invaders appear (around the tower?) and call
  12.     -- out to traitor/hand    
  13.     local tower = G.GetCogName("Tower");
  14.     local towerPos = tower.GetPosition();
  15.     Camera.CinemaLookAt( tower );    
  16.  
  17.     -- Rotate around while looking at the tower
  18.     TraitorTalk("Hi! Welcome to Base Invaders!  My name is 'Traitor'.");
  19.     
  20.     Camera.CinemaMove( towerPos + Vector3(-40,65,-40), towerPos, 3 );
  21.     GameWait(3)
  22.  
  23.     Camera.CinemaRotate( -3.14 * 1.5 / 9.0 ) -- Rotate 3/4 around the tower in 9 seconds
  24.     GameWait(3)
  25.  
  26.     -- Spawn cinema basic(s)
  27.     local CinemaInvader = G.CreateAt( "Basic", towerPos + Vector3( -40, 0, 40 ) );
  28.     CinemaInvader.TurnOffAI()
  29.     
  30.     TraitorTalk("The tower sure is looking great today!");
  31.     GameWait(6)
  32.     Camera.CinemaRotate( 0 )
  33.     
  34.     -- Look at cinema basic
  35.     local invPos = CinemaInvader.GetPosition()
  36.     Camera.CinemaMove( towerPos + Vector3(40,65,-25), invPos, 0.5 );
  37.     Camera.CinemaLookAt( CinemaInvader );
  38.     
  39.     -- 3. Speech
  40.     local CinemaInvader2 = G.CreateAt( "Basic",  towerPos + Vector3( 5, 0, 40 ) );
  41.     CinemaInvader2.TurnOffAI()
  42.     
  43.     G.SayPhraseScript( "Traitor! You\n have allied\n with the hand!", CinemaInvader );
  44.     GameWait(3)
  45.     
  46.     local CinemaInvader3 = G.CreateAt( "Basic", towerPos + Vector3( -40, 0, 5 ) );
  47.     CinemaInvader3.TurnOffAI()
  48.         
  49.     TraitorTalk( "Oh no, the invaders, they've found me!" );
  50.     GameWait(3)
  51.     
  52.  
  53.     CinemaInvader.Hop( 20 )
  54.     G.SayPhraseScript( "We will destroy\n the tower and\n you with it!" , CinemaInvader );
  55.     GameWait(2)
  56.  
  57.     G.SayPhraseScript( "Yeah!" , CinemaInvader2 );
  58.     CinemaInvader2.Hop(20)
  59.  
  60.     invPos = CinemaInvader2.GetPosition()
  61.     Camera.CinemaMove( towerPos + Vector3(40,65,-40), invPos, 0.5 );
  62.     Camera.CinemaLookAt( CinemaInvader2 );
  63.  
  64.     GameWait(2)
  65.  
  66.     G.SayPhraseScript( "It's going\n down!" , CinemaInvader3 );
  67.  
  68.     invPos = CinemaInvader3.GetPosition()
  69.     Camera.CinemaMove( towerPos + Vector3(40,65,-40), invPos, 0.5 );
  70.     Camera.CinemaLookAt( CinemaInvader3 );
  71.  
  72.     CinemaInvader3.Hop( 20 )
  73.     
  74.     TraitorTalk( "Quickly! Eliminate them before they destroy the base!" );
  75.     GameWait(5)
  76.  
  77.     Camera.EndCinemaLookAt();
  78.     CinemaInvader.TurnOnAI()
  79.     CinemaInvader2.TurnOnAI()
  80.     CinemaInvader3.TurnOnAI()
  81.  
  82.     -- 4. End (Revert to tower?)
  83.  
  84. end
  85.  
  86.  
  87. -- This is the sequence where the Miner is introduced
  88. function MinerCinematic()
  89.     
  90.     TraitorTalk( "Wait, What's that?" );
  91.     
  92.     local tower = G.GetCogName("Tower");
  93.     local towerPos = tower.GetPosition();
  94.     
  95.     -- 1. Spawn cinema miner
  96.     TrapPlace( "wall", Vector3(126,0,130), Vector3(1,0,0));
  97.     TrapPlace( "wall", Vector3(130,0,126), Vector3(1,0,0));
  98.     
  99.     TrapPlace( "wall", Vector3(142,0,142), Vector3(1,0,0));
  100.     TrapPlace( "wall", Vector3(130,0,130), Vector3(1,0,0));
  101.     TrapPlace( "wall", Vector3(150,0,150), Vector3(1,0,0));
  102.     TrapPlace( "wall", Vector3(134,0,142), Vector3(1,0,0));
  103.     TrapPlace( "wall", Vector3(142,0,134), Vector3(1,0,0));
  104.     TrapPlace( "wall", Vector3(138,0,132), Vector3(1,0,0));
  105.     TrapPlace( "wall", Vector3(126,0,120), Vector3(1,0,0));
  106.     TrapPlace( "wall", Vector3(120,0,130), Vector3(1,0,0));
  107.     TrapPlace( "wall", Vector3(146,0,150), Vector3(1,0,0));
  108.  
  109.     local CinemaInvader  = G.CreateAt( "Miner", Vector3( 115, 0, 125 ) );
  110.     local CinemaInvader2 = G.CreateAt( "Miner", Vector3( 120, 0, 120 ) );
  111.     local CinemaInvader3 = G.CreateAt( "Miner", Vector3( 125, 0, 115 ) );
  112.  
  113.     -- 2. Look at cinema basic
  114.     Camera.CinemaMove( Vector3(170,25,170), Vector3(126,0,130), 2 );
  115. --    Camera.CinemaLookAt( CinemaInvader );
  116.     GameWait(2)
  117.     
  118.     G.SayPhraseScript( "Who Put all\n these walls\n here!?!" , CinemaInvader );    
  119.     -- 3. Have him attack several walls
  120.     GameWait(2)
  121.     
  122.     TraitorTalk( "Oh no! Miners! They'll make short work of our defenses!" );
  123.     GameWait(3)
  124.     G.EndCurrentPhrase( CinemaInvader )
  125.     
  126.     G.SayPhraseScript( "ARRGH! \nMore walls!" , CinemaInvader3 );    
  127.     GameWait(2)
  128.     G.EndCurrentPhrase( CinemaInvader3 )
  129.  
  130.     G.SayPhraseScript( "I Hate \nthese Walls!" , CinemaInvader2 );    
  131.  
  132.     TraitorTalk( "They sound ticked off, better get rid of them quickly!" );
  133.     GameWait(2)
  134.     G.EndCurrentPhrase( CinemaInvader2 )
  135.  
  136.     G.SayPhraseScript( "DIE you \ndarn Walls!" , CinemaInvader3 );    
  137.     GameWait(3)
  138.     G.EndCurrentPhrase( CinemaInvader3 )
  139.  
  140.     Camera.EndCinemaLookAt();
  141.     -- 4. End (Revert to tower?)
  142.  
  143. end
  144.  
  145. -- Create ~3 spikers, kill them with traps
  146. function SpikerCinematic()
  147.  
  148.     local tower = G.GetCogName("Tower");
  149.     local towerPos = tower.GetPosition();
  150.  
  151.     TrapPlace( "hammer", towerPos + Vector3(80,0, 20), Vector3(0,0,-1));
  152.     TrapPlace( "hammer", towerPos + Vector3(54,0,-40), Vector3(0,0,1));
  153.     TrapPlace( "hammer", towerPos + Vector3(70,0,-20), Vector3(0,0,1));
  154.  
  155.     TrapPlace( "fan", towerPos + Vector3(50,0, 10), Vector3(0,0,-1));
  156.         
  157.  
  158.     local CinemaInvader   = G.CreateAt( "Spiker", towerPos + Vector3( 130, 0,  0 ) );
  159.     local CinemaInvader2  = G.CreateAt( "Spiker", towerPos + Vector3( 130, 0,  20 ) );
  160.     local CinemaInvader3  = G.CreateAt( "Spiker", towerPos + Vector3( 130, 0, -20 ) );
  161.  
  162.     Camera.CinemaMove( towerPos + Vector3( 5, 60,  0 ), towerPos + Vector3( 100,0,0 ), 2 );
  163.     Camera.CinemaLookAt( CinemaInvader );
  164.     GameWait(2)
  165.     
  166.     -- Spiker appears:
  167.     G.SayPhraseScript( "Rock on!" , CinemaInvader );
  168.     G.SayPhraseScript( "Hardcore!", CinemaInvader2 );
  169.     G.SayPhraseScript( "Punk'd!"  , CinemaInvader3 );
  170.  
  171.     TraitorTalk( "Spikers! They're tough, and You can't grab them. " );
  172.     GameWait(3)
  173.  
  174.     G.SayPhraseScript( "Can't Touch\n this!" , CinemaInvader );
  175.  
  176.     TraitorTalk( "But like most invaders they aren't very bright. " );
  177.     GameWait(4)
  178.  
  179.     TraitorTalk( "Traps will get rid of them easily. " );
  180.     GameWait(5)
  181.     
  182. end
  183.  
  184.  
  185.  
  186.  
  187. CreditsText = {}
  188. CreditsText[0] = "Basic Invaders"
  189. CreditsText[1] = "Credits"
  190. CreditsText[2] = "Programming By"
  191. CreditsText[3] = "Matt Miner"
  192. CreditsTextLength = 4
  193. CreditsInvaders = {}
  194.  
  195.  
  196. -- Each invader walks past the camera (on it way to the tower)
  197. function CreditsCinematic()
  198.     
  199.     Camera.CinemaMove( Vector3(170,15,170), Vector3(126,0,130), 2 );
  200.     
  201.     -- Each invader passes by, while saying their text
  202.     local curText = 0
  203.     while( curText < CreditsTextLength ) do
  204.  
  205.         -- Create the invader        
  206.         local CinemaInvader  = G.CreateAt( "Basic", Vector3( 125, 0, 130 ) );
  207.         
  208.         GameWait(3)
  209.         curText = curText + 1;
  210.     end
  211.     
  212. end
  213.  
  214.  
  215.  
  216.  
  217. --Common Level Start Code
  218. function LevelStartup()
  219.  
  220.     G.Create( "MenuData/HudCog.xml" );
  221.     G.Create( "Data/GameCamera.xml" );
  222.     G.Create( "Data/CursorCog.xml" );
  223.  
  224.     MainLevel = G.Create( "Data/Levels/Campaign1.xml" );
  225.     MainLevel.CreateLevel();
  226.  
  227.     G.SetInvSpeed( 20 );
  228.     HUD.EnterLevel();
  229.     G.SetGameState( InLevel );
  230.     G.EarnPoints( 100 );
  231.     G.SetMaxKills(0);
  232.     
  233.     G.SetLightTime( 5 );
  234.     G.PostP( "None" );
  235.  
  236.     HUD.Message( "VictoryCondition" , "SetText", "Survive 3 Invasion Waves!"  );
  237.     HUD.Message( "LossCondition" , "SetText", "If the Tower falls you lose." );
  238.     
  239.     TraitorCanBeHidden = true
  240.     ----TraitorTalk(" ");
  241. end
  242.  
  243. LevelStartup()
  244.  
  245.  
  246. function LevelIntro()
  247.     
  248.     local tempPos = Tower.GetPosition()
  249.     Camera.LookAtPosition( tempPos )
  250.  
  251.     -- There is no intro for this level:
  252.     gameStartTime = GameTime;
  253.     ColorTextPopup( "Level 1: Traitor's Trouble", Color(1,1,1,1) )
  254.  
  255.     G.DisableTrapAll()
  256.  
  257.     DisableTraitor()
  258.     GameWait(1.5)
  259.     
  260.     StartCinematic();
  261.  
  262.         BasicCinematic();
  263.         --MinerCinematic();
  264.  
  265.     EndCinematic();
  266.  
  267.  
  268.  
  269.     --TraitorTalk("Yeah that's right I am Tat");    
  270.     --TraitorTalk("Hi! Welcome to base invaders!  My name is 'Traitor'.  Say, Thats a real nice tower you've got there.");    
  271.     --GameWait(8)
  272.     --TraitorTalk("However, my invader brothers are Bataphobic.  That is, they're afraid of tall buildings.");
  273.     --GameWait(8)
  274.     --TraitorTalk("Me? Don't be silly, I'm not scared of your goofy tower.");
  275.     --GameWait(5)
  276.     --TraitorTalk("In fact, I'm gonna live in here and help you!");
  277.     --GameWait(4)
  278.     --TraitorTalk("My generosity comes with a price, though.");
  279.     --GameWait(4)
  280.     --TraitorTalk("You'll have to protect me against the other invaders.");
  281.     --GameWait(5)
  282.     --TraitorTalk("They're not too happy with me helping the owner of that tall, tall tower.");
  283.     --GameWait(7)
  284.     --TraitorTalk("They'll be coming soon to  *gulp*  hurt me!");
  285.     --GameWait(4)
  286. end
  287.  
  288. function LevelSequence()
  289.     
  290.     -- 1st Have a tower and some walls and let the Basic guys attack.
  291.     Traitor.SetGuiPosition( "TraitorWindow"  , Vector3(0.6, -0.5, 1) );
  292.     
  293.     -- Start Spawning thr guys
  294.     BasicWave = createSpawnStruct()
  295.     
  296.     BasicWave.Prob.Basic    = 1.0;
  297.     
  298.     BasicWave.SpawnSpeed    = 0.3;
  299.     BasicWave.MaxSpawn        = 3;
  300.     BasicWave.TotalSpawn    = 7;
  301.     BasicWave.GroupPercent    = 0.5;
  302.     BasicWave.GroupSize        = 3;
  303.     BasicWave.WhereToSpawn    = SmallCircleAroundTower
  304.  
  305.     G.SetInvSpeed( 10 );    -- Slow the first waves
  306.  
  307.     InvaderTextPopup( "Basic" );
  308.     AddWave( "BasicAttack", BasicWave );
  309.     G.SetMaxKills(10);    
  310.     
  311.     TraitorTalk("Look out! Here they come!")
  312.     GameWait(4)
  313.     TraitorTalk("Get rid of them by throwing them with your hand.")
  314.     InvadersKilledWait(8)
  315.     
  316.     TraitorTalk( "I think they're letting up!" )
  317.     GameWait(3)
  318.     InvadersKilledWait( 10 ) --WaitForClearEnemies()                            -- This doesn't actually wait for all 20enemies to have been killed
  319.     StopWave( "BasicAttack" );    
  320.     
  321.     TraitorTalk( "They're gone! But we should reinforce the base in case more come!" )
  322.     GameWait(8)
  323.     
  324.     TrapTextPopup("Walls")
  325.     G.EarnPoints( 50 )
  326.     G.EnableTrap("wall");
  327.     TraitorTalk( "Try dropping some walls to fortify our defenses!" )
  328.     GameWait(7)
  329.  
  330.     TraitorTalk( "You can drag out a line of walls, by holding the mouse button!" )
  331.     GameWait(7)
  332.     
  333.     GameWaitOrMoney(20)        -- This should have a countdown!
  334.  
  335.     StartCinematic();
  336.         MinerCinematic();
  337.     EndCinematic();
  338.     
  339.     BasicWave.Prob.Basic    = 0.0;
  340.     BasicWave.Prob.Miner    = 1.0;
  341.     BasicWave.TotalSpawn    = 17;
  342.  
  343.     InvaderTextPopup( "Miner" );
  344.  
  345.     G.SetInvSpeed( 15 );    -- Slightly faster for the Miners
  346.         
  347. --    TraitorTalk("Look out here comes some Miners!")
  348. --    GameWait(3)
  349. --    TraitorTalk("They're ticked off, and will attack anything they see!")
  350. --    GameWait(6)
  351.     AddWave( "MinerAttack", BasicWave );
  352.     G.SetMaxKills(30);
  353.     TraitorTalk("Throw them with the hand before they reach the tower!")    
  354.     InvadersKilledWait(25)
  355.     
  356.     TraitorTalk( "Not that many Miners Left!" )
  357.     GameWait(3)
  358.     InvadersKilledWait( 30 ) --WaitForClearEnemies()
  359.     StopWave( "MinerAttack" );    
  360.     
  361.     TraitorTalk( "That was tough! We need to get some better defenses here!" )
  362.     GameWait(6)
  363.     
  364.     TrapTextPopup("Fans")
  365.     G.EarnPoints( 50 )
  366.     G.EnableTrap("fan");
  367.     TraitorTalk( "Here are the blueprints for a Fan Trap.  Use fans to blow invaders around, even into other traps!" )
  368.     G.EarnPoints( 25 )    
  369.     GameWait(10)
  370.     
  371.     TrapTextPopup("Hammers")    
  372.     G.EarnPoints( 50 )
  373.     G.EnableTrap("hammer");
  374.     
  375.     TraitorTalk( "Here are the blueprints for a Hammer Trap, too.  They will smash invaders flat!" )
  376.     G.EarnPoints( 25 )
  377.     GameWait(10)
  378.     
  379.     TraitorTalk( "Place some traps around the base.");
  380.     GameWait(10)
  381.  
  382.     StartCinematic();
  383.         SpikerCinematic();
  384.     EndCinematic();
  385.  
  386.     InvaderTextPopup( "Spiker" );
  387.     
  388.     TraitorTalk( "Hurry up and finish those defenses.  I think I see more coming!");
  389.     GameWaitOrMoney(25)
  390.     
  391.     TraitorTalk("Look out here come some more Spikers!")
  392.     GameWait(5)
  393. --    TraitorTalk("Their spiked helmets prevent you from grabbing them!")
  394. --    GameWait(6)
  395.  
  396.     G.SetInvSpeed( 20 );    -- Normal speed for the spikers
  397.     
  398.     BasicWave.Prob.Basic    = 1.0;
  399.     BasicWave.Prob.Miner    = 1.0;
  400.     BasicWave.Prob.Spiker    = 2.0;
  401.     BasicWave.TotalSpawn    = 32;
  402.  
  403.     AddWave( "SpikerAttack", BasicWave );    
  404.     G.SetMaxKills(65);
  405.     
  406.     TraitorTalk("Smash those Spikers with hammers or drop a trap on them!")    
  407.     InvadersKilledWait(60)
  408.     
  409.     TraitorTalk( "Just a few more!" )
  410.     GameWait(3)
  411.     InvadersKilledWait( 65 ) --WaitForClearEnemies()
  412.     StopWave( "SpikerAttack" );
  413.     
  414.     TraitorTalk( "Wow you survived! But this is just one Day!" )
  415.     GameWait(4)
  416.  
  417.     G.SetGameState( Victory );
  418.  
  419.     TraitorTalk( "Those invaders will be back, but don't worry, I'll have some new tricks in store for them tomorrow!" )
  420.     GameWait(5)
  421.     
  422.         
  423. end
  424.  
  425. levelRoutine = coroutine.create(LevelIntro);
  426.  
  427. GMain["LevelUpdate"] = LevelUpdate;
  428.  
  429.  
  430.